package servletpackage;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import news.bll.news.NewsDaoImpl;
import news.entity.News;

public class GoNewsModifyServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6420009472084578612L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;charset=UTF-8");
		int nid = Integer.parseInt(req.getParameter("nid"));
		int pageNo = Integer.parseInt(req.getParameter("pageNo"));
		NewsDaoImpl ndi = new NewsDaoImpl();
		News n = ndi.getANews(nid);
		req.setAttribute("nid", nid);
		req.setAttribute("pageNo", pageNo);
		req.setAttribute("news", n);
		req.getRequestDispatcher("/WEB-INF/jsp/news_modify.jsp").forward(req, resp);
	}
}
